﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Auction_Intranet.Models
{
    [Bind(Include = "userBalance, name, groupMember1, groupMember2, groupMember3, groupMember4, groupMember5, groupMember6, groupMember7 , addedCredit")]
    public class CreateGroupModel 
    {
        DataRepository m_rep = new DataRepository();
        public CreateGroupModel() 
        {
            var username = (HttpContext.Current.User.Identity.Name).Split('\\')[1];
            var user = m_rep.GetUserByUsername(username);
            userId = user.Id;
            userBalance = user.Balance;
            success = 0;
        }

        public int userId { get; set; }

        public int userBalance { get; set; }

        [Required(ErrorMessage = "Name field is requered.")]
        [Display(Name = "Group name")]
        public string name { get; set; }

        public DateTime created { get; set; }

        [Display(Name = "Credit to add")]
        [RegularExpression("([1-9][0-9]*)", ErrorMessage = "Positive number in credit field is required.")]       
        public int addedCredit { get; set; }

        public string groupMember1 { get; set; }

        public string groupMember2 { get; set; }

        public string groupMember3 { get; set; }

        public string groupMember4 { get; set; }

        public string groupMember5 { get; set; }

        public string groupMember6 { get; set; }

        public string groupMember7 { get; set; }

        public int success { get; set; }
    }
}
